//=============================================================
// LocalPara.h - 
//=============================================================
//Define the local ability

#define LOCAL_DEFAULT_BEACON_PERIOD			100		//ms
#define LOCAL_DEFAULT_ATIM_WINDOW			0
#define LOCAL_DEFAULT_ERP_CAPABILITY		0x0431	//0x0001:	ESS
													//0x0010:	Privacy
													//0x0020:	short preamble
													//0x0400:	short slot time
#define LOCAL_DEFAULT_LISTEN_INTERVAL		5

//#define LOCAL_DEFAULT_24_CHANNEL_NUM		11		// channel 1..11
#define LOCAL_DEFAULT_24_CHANNEL_NUM		13		// channel 1..13
#define LOCAL_DEFAULT_5_CHANNEL_NUM			8		// channel 36..64

#define LOCAL_USA_24_CHANNEL_NUM			11
#define LOCAL_USA_5_CHANNEL_NUM				12
#define LOCAL_EUROPE_24_CHANNEL_NUM			13
#define LOCAL_EUROPE_5_CHANNEL_NUM			19
#define LOCAL_JAPAN_24_CHANNEL_NUM			14
#define LOCAL_JAPAN_5_CHANNEL_NUM			11
#define LOCAL_UNKNOWN_24_CHANNEL_NUM		14
#define LOCAL_UNKNOWN_5_CHANNEL_NUM			34	//not include 165


#define psLOCAL			(&(Adapter->sLocalPara))

#define MODE_802_11_BG			0
#define MODE_802_11_A			1
#define MODE_802_11_ABG			2
#define MODE_802_11_BG_IBSS		3
#define MODE_802_11_B			4
#define MODE_AUTO				255

#define BAND_TYPE_DSSS			0
#define BAND_TYPE_OFDM_24		1
#define BAND_TYPE_OFDM_5		2

//refer Bitmap2RateValue table
#define LOCAL_ALL_SUPPORTED_RATES_BITMAP		0x130c1a66	//the bitmap value of all the H/W supported rates
															//1, 2, 5.5, 11, 6, 9, 12, 18, 24, 36, 48, 54
#define LOCAL_OFDM_SUPPORTED_RATES_BITMAP		0x130c1240	//the bitmap value of all the H/W supported rates
															//except to non-OFDM rates
															//6, 9, 12, 18, 24, 36, 48, 54

#define LOCAL_11B_SUPPORTED_RATE_BITMAP			0x826
#define LOCAL_11B_BASIC_RATE_BITMAP				0x826
#define LOCAL_11B_OPERATION_RATE_BITMAP			0x826
#define LOCAL_11G_BASIC_RATE_BITMAP				0x826		//1, 2, 5.5, 11
#define LOCAL_11G_OPERATION_RATE_BITMAP			0x130c1240	//6, 9, 12, 18, 24, 36, 48, 54
#define LOCAL_11A_BASIC_RATE_BITMAP				0x01001040	//6, 12, 24
#define LOCAL_11A_OPERATION_RATE_BITMAP			0x120c0200	//9, 18, 36, 48, 54



#define PWR_ACTIVE		0
#define PWR_SAVE		1
#define PWR_TX_IDLE_CYCLE			6

//bPreambleMode and bSlotTimeMode
#define AUTO_MODE			0
#define LONG_MODE			1

//Region definition
#define REGION_AUTO			0xff
#define REGION_UNKNOWN		0
#define REGION_EUROPE		1	//ETSI
#define REGION_JAPAN		2	//MKK
#define REGION_USA			3	//FCC
#define	REGION_FRANCE		4	//FRANCE
#define REGION_SPAIN		5	//SPAIN
#define REGION_ISRAEL		6	//ISRAEL
//#define REGION_CANADA		7	//IC

#define MAX_BSS_DESCRIPT_ELEMENT		32
#define MAX_PMKID_CandidateList         16

//High byte : Event number,  low byte : reason
//Event definition
//-- SME/MLME event
#define EVENT_RCV_DEAUTH					0x0100
#define EVENT_JOIN_FAIL						0x0200
#define EVENT_AUTH_FAIL						0x0300
#define EVENT_ASSOC_FAIL					0x0400
#define EVENT_LOST_SIGNAL					0x0500
#define EVENT_BSS_DESCRIPT_LACK				0x0600
#define EVENT_COUNTERMEASURE				0x0700
#define EVENT_JOIN_FILTER					0x0800
//-- TX/RX event
#define EVENT_RX_BUFF_UNAVAILABLE			0x4100

#define EVENT_CONNECT						0x8100
#define EVENT_DISCONNECT					0x8200
#define EVENT_SCAN_REQ						0x8300

//Reason of Event
#define EVENT_REASON_FILTER_BASIC_RATE		0x0001
#define EVENT_REASON_FILTER_PRIVACY			0x0002
#define EVENT_REASON_FILTER_AUTH_MODE		0x0003
#define EVENT_REASON_TIMEOUT				0x00ff

// 20061108 WPS IE buffer
#define MAX_IE_APPEND_SIZE					256 + 4 // Due to [E id][Length][OUI][Data] may 257 bytes

typedef struct _EVENTLOG
{
	USHORT		Count;			//Total count from start
	USHORT		index;			//Buffer index, 0 ~ 63
	ULONG		EventValue[64];	//BYTE 3~2 : count, BYTE 1 : Event, BYTE 0 : reason
} Event_Log, *pEvent_Log;

typedef struct _ChanInfo
{
	UCHAR		band;
	UCHAR		ChanNo;
} ChanInfo, *pChanInfo;

typedef struct _CHAN_LIST
{
	USHORT				Count;
	ChanInfo		Channel[50]; // 100B
} CHAN_LIST, *psCHAN_LIST;

typedef struct _RadioOff
{
	UCHAR			boHwRadioOff;
	UCHAR			boSwRadioOff;
} RadioOff, *psRadioOff;

//===========================================================================
typedef struct LOCAL_PARA
{
	UCHAR			PermanentAddress[ MAC_ADDR_LENGTH + 2 ]; 	// read from EPROM, manufacture set for each NetCard
    UCHAR    		ThisMacAddress[ MAC_ADDR_LENGTH + 2 ];			// the driver will use actually.

	UINT			MTUsize;				// Ind to Uplayer, Max transmission unit size

	UCHAR			region_INF;	//region setting from INF
	UCHAR			region;		//real region setting of the device
	UCHAR			Reserved_1[2];

    //// power-save variables
    UCHAR  		  	iPowerSaveMode;     // 0 indicates it is on, 1 indicates it is off
	UCHAR			ShutDowned;
	UCHAR			ATIMmode;
	UCHAR			ExcludeUnencrypted;

	USHORT			CheckCountForPS;	//Unit ime count for the decision to enter PS mode
	UCHAR			boHasTxActivity;	//tx activity has occurred
	UCHAR			boMacPsValid;		//Power save mode obtained from H/W is valid or not

	//// Rate
	UCHAR			TxRateMode;				// Initial, input from Registry, may be updated by GUI
											//Tx Rate Mode: auto(DTO on), max, 1M, 2M, ..
	UCHAR			CurrentTxRate;			// The current Tx rate
	UCHAR			CurrentTxRateForMng;	// The current Tx rate for management frames
										// It will be decided before connection succeeds.
	UCHAR			CurrentTxFallbackRate;

	//for Rate handler
	UCHAR			BRateSet[32];			//basic rate set
	UCHAR			SRateSet[32];			//support rate set

	UCHAR			NumOfBRate;
	UCHAR			NumOfSRate;
	UCHAR			NumOfDsssRateInSRate;	//number of DSSS rates in supported rate set
	UCHAR			reserved1;

	ULONG			dwBasicRateBitmap;		//bit map of basic rates
	ULONG			dwSupportRateBitmap;	//bit map of all support rates including
										//basic and operational rates

	////For SME/MLME handler
	USHORT			wOldSTAindex;			// valid when boHandover=TRUE, store old connected STA index
	USHORT			wConnectedSTAindex;		// Index of peerly connected AP or IBSS in 
										// the descriptionset.
    USHORT			Association_ID;     	// The Association ID in the (Re)Association
            	                    	// Response frame.
    USHORT			ListenInterval;     	// The listen interval when SME invoking MLME_
            	                    	// (Re)Associate_Request().

	RadioOff		RadioOffStatus;
	UCHAR			Reserved0[2];

	UCHAR			boMsRadioOff;			// Ndis demands to be true when set Disassoc. OID and be false when set SSID OID.
	UCHAR			boAntennaDiversity;		//TRUE/ON or FALSE/OFF
	UCHAR			bAntennaNo;				//which antenna
	UCHAR			bConnectFlag;			//the connect status flag for roaming task

	UCHAR			RoamStatus;
	UCHAR			reserved7[3];

	ChanInfo	CurrentChan;			//Current channel no. and channel band. It may be changed by scanning.
	UCHAR			boHandover;				// Roaming, Hnadover to other AP.
	UCHAR			boCCAbusy;

	USHORT			CWMax;					// It may not be the real value that H/W used
	UCHAR			CWMin;					// 255: set according to 802.11 spec.
	UCHAR			reserved2;

	//11G:
	UCHAR			bMacOperationMode;		// operation in 802.11b or 802.11g
	UCHAR			bSlotTimeMode;			//AUTO, LONG
	UCHAR			bPreambleMode;			//AUTO, LONG
	UCHAR			boNonERPpresent;

	UCHAR			boProtectMechanism;	// H/W will take the necessary action based on this variable
	UCHAR			boShortPreamble;	// H/W will take the necessary action based on this variable
	UCHAR			boShortSlotTime;	// H/W will take the necessary action based on this variable
	UCHAR			reserved_3;

	ULONG       	RSN_IE_Bitmap;		//added by WS
	ULONG      		RSN_OUI_Type;		//added by WS

	//For the BSSID
	UCHAR			HwBssid[MAC_ADDR_LENGTH + 2];
	ULONG			HwBssidValid;

	//For scan list
	UCHAR			BssListCount;							//Total count of valid descriptor indexes
	UCHAR			boReceiveUncorrectInfo;	//important settings in beacon/probe resp. have been changed
	UCHAR			NoOfJoinerInIbss;
	UCHAR			reserved_4;

	UCHAR			BssListIndex[ (MAX_BSS_DESCRIPT_ELEMENT+3) & ~0x03 ];	//Store the valid descriptor indexes obtained from scannings
	UCHAR			JoinerInIbss[ (MAX_BSS_DESCRIPT_ELEMENT+3) & ~0x03 ];	//save the BssDescriptor index in this
														//IBSS. The index 0 is local descriptor
														//(psLOCAL->wConnectedSTAindex).
														//If CONNECTED : NoOfJoinerInIbss >=2
														//		else   : NoOfJoinerInIbss <=1

	//// General Statistics, count at Rx_handler or Tx_callback interrupt handler
    ULONG64 	GS_XMIT_OK;				// Good Frames Transmitted
    ULONG64 	GS_RCV_OK;				// Good Frames Received
	ULONG		GS_RCV_ERROR;			// Frames received with crc error
	ULONG		GS_XMIT_ERROR;			// Bad Frames Transmitted
	ULONG		GS_RCV_NO_BUFFER;		// Receive Buffer underrun
	ULONG		GS_XMIT_ONE_COLLISION;	// one collision
	ULONG		GS_XMIT_MORE_COLLISIONS;// more collisions

    //================================================================
    // Statistics (no matter whether it had done successfully) -wkchen
    //================================================================
    ULONG		   	_NumRxMSDU;
    ULONG	   		_NumTxMSDU;
    ULONG	   		_dot11WEPExcludedCount;
    ULONG	   		_dot11WEPUndecryptableCount;
    ULONG	   		_dot11FrameDuplicateCount;

	ChanInfo	IbssChanSetting;	// 2B. Start IBSS Channel setting by registry or WWU.
	UCHAR		reserved_5[2];		//It may not be used after considering RF type,
									//region and modulation type.

	CHAN_LIST	sSupportChanList;	// 86B. It will be obtained according to RF type and region
	UCHAR		reserved_6[2];		//two variables are for wep key error detection added by ws 02/02/04

    ULONG	      bWepKeyError;
    ULONG         bToSelfPacketReceived;
    ULONG         WepKeyDetectTimerCount;
    
	Event_Log	EventLog;

	USHORT		SignalLostTh;
	USHORT		SignalRoamTh;

	// 20061108 WPS IE Append
	UCHAR		IE_Append_data[MAX_IE_APPEND_SIZE];
	USHORT		IE_Append_size;
	USHORT		reserved_7;

} WB_LOCALDESCRIPT, *PWB_LOCALDESCRIPT;


